<?php

namespace App\Console\Commands\Assess;

use App\Services\Assess\OrderAndCustomersOrderService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class SynBrand extends Command
{
    /**
     * linux定时同步订单 /usr/local/phpstudy/soft/php/php-7.4.0/bin/php /www/admin/winsdom_seller/artisan synBrand
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'synBrand
                            {--status=}
                            {--warehouse_ship_date=}
                            {--order_code=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '同步易仓平台订单信息';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $status = $this->option('status');
        $orderCode = $this->option('order_code');
        $warehouseShipDate = $this->option('warehouse_ship_date');
        $OrderAndCustomersOrderService = new OrderAndCustomersOrderService();
        $params = [];
        if (!empty($status)) $params['status'] = $status;
        if (!empty($orderCode)) $params['order_code'] = $orderCode;

        //获取最近发货多少天的数据
        if (!empty($warehouseShipDate)) {
            $warehouseShipDateStar = date('Y-m-d H:i:s', strtotime("-$warehouseShipDate day"));
            $warehouseShipDateEnd = date('Y-m-d H:i:s');
            $params['warehouse_ship_date'] = ['warehouse_ship_date_start' => $warehouseShipDateStar, 'warehouse_ship_date_end' => $warehouseShipDateEnd];
        }
        $OrderAndCustomersOrderService->synBrand($params);
        exit('SUCCESS');
    }
}



